package no.ntnu.idi.deid.decision.validators;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import no.ntnu.idi.deid.documentunits.Token;

public class TimeValidator {
	
	public static boolean validateTimeFromTwoTokens(Token tok1, Token tok2) {
		String timeString = (tok1.getStripped()+tok2.getStripped()).replaceAll("[^0-9]", "");
		return validateTime(timeString);
	}
	
	public static boolean validateTime(String str){
		String timeString = str.replaceAll("[^0-9]", "");
		Pattern pattern = Pattern.compile("((0|1)?[0-9]|2[0-3])([0-5][0-9])");
		Matcher matcher = pattern.matcher(timeString);
		return matcher.matches();
	}

}
